<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.anhry.app.safety.util.Util" />
<%@ include file="/WEB-INF/pages/share/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>用户添加</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="<%=basePath+Util.SKIN%>/css/right.css" type="text/css"
			rel="stylesheet">
		<script type="text/javascript" src="<%=basePath%>/js/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="<%=basePath%>/js/check_jquery.js"></script>
		<script type="text/javascript" src="<%=path%>/js/selected.js"></script>
		<script type="text/javascript">
		var b = true;
		$(document).ready(function(){
			$("#bit1").blur(function() {
				var gs = encodeURI(encodeURI($("#bit1").val()));
	    		if(gs==""){
		         $("#userSpan").html("用户名不能为空!").addClass("note5");
		         return false;
		        }
		        var urls="<%=basePath%>/admin/sys_userCheck.action?userName="+gs;
				$.post(urls,function(data){
					if(data=="0"){
						$("#userSpan").html("<font color='green'>此用户可以使用！</font>");
						b = true;
						return true;
					}else if(data!="0"){
						$("#userSpan").html("该用户名已存在，请重新填写!").addClass("note5");
						b = false;
						return false;
					}
				});
			});
		});
    	
    	function toSubmit(){
    		if(!b){
    			alert('该用户名已存在，请重新填写!');
    			$("#userSpan").html("该用户名已存在，请重新填写!").addClass("note5");
    			return false;
    		}
    		return true;
    	}
    	
       	function changeGrade(rid){
	   		var urls='<%=basePath%>/admin/sys_loadDept.action?gradeId='+rid
	   		buildSelect(rid, 'unitId',urls,'1');
	   		if(rid == 9) {
	   			$("#countrySpan").css("display","");
	   		} else {
	   			$("#countrySpan").css("display","none");
	   		}
	   	}
	   	function changeUnit(uid){
	   		var rid=document.getElementById("bselect1").value;
	   		var urls="<%=basePath%>/admin/sys_loadDept.action?unitId="+uid+"&gradeId="+rid;
	   		buildSelect(uid, 'deptId',urls,'1');
	   	}
	   	function changeDept(did){
	   		if(	$("#countrySpan").css("display") !="none") {
	   		var rid=document.getElementById("bselect1").value;
	   			var urls="<%=basePath%>/admin/sys_loadDept.action?unitId="+did+"&gradeId="+rid;
	   			buildSelect(did, 'streetId',urls,'1');
	   		}
	   	}
	</script>
	</head>

	<body onload="initSelArray('unitId:1','deptId:1','streetId:1');">
		<div class="body-box">
			<div class="map">
				<div class="map_con">
					您当前的位置：系统管理 &gt; 用户管理 &gt; 用户添加
				</div>

			</div>
			<div id="container">
				<form action="<%=basePath%>/admin/sys_userSave.action" method="post"
					name="form1">
					<table border="0" cellspacing="0" cellpadding="0" width="100%"
						class="info_table">
						<tr>
							<td colspan="4" class="title_li">
								用户添加
							</td>
						</tr>
						<tr>
							<td width="15%" class="title_td">
								用户名：
							</td>
							<td width="35%">
								<input type="text" name="userName" class="info_input" value=""
									id="bit1" />
								<SPAN class="note4" id="userSpan">*</SPAN>
							</td>
							<td width="15%" class="title_td">
								密码：
							</td>
							<td>
								<input type="text" name="userPwd" class="info_input" value=""
									id="bit2" />
								<SPAN class="note4">*</SPAN>
							</td>
						</tr>
						<tr>
							<td class="title_td">
								真实姓名：
							</td>
							<td>
								<input type="text" name="userRealName" class="info_input"
									value="" id="bit3" />
								<SPAN class="note4">*</SPAN>
							</td>
							<td class="title_td">
								性别：
							</td>
							<td>
								<s:radio list="#{1:'男',0:'女'}" name="userSex" value="1"
									theme="simple"></s:radio>
							</td>
						</tr>
						<tr>
							<td class="title_td">
								用户级别：
							</td>
							<td colspan="3">
								<s:select list="gradeList" name="gradeId" listKey="id"
									listValue="gradeName" headerKey="" headerValue="请选择"
									theme="simple" cssStyle="width:155px;margin-left:5px;"
									id="bselect1" onchange="changeGrade(this.value);"></s:select>
								<SPAN class="note4">*</SPAN>
							</td>
						</tr>
						<tr>
							<td class="title_td">
								用户部门：
							</td>
							<td colspan="3">
								<s:select list="#{}" name="unitId" headerKey=""
									headerValue="请选择" theme="simple"
									cssStyle="width:155px;margin-left:5px;" id="bselect2"
									onchange="changeUnit(this.value);"></s:select>
								<SPAN class="note4">*</SPAN>
								<s:select list="#{}" name="deptId" headerKey=""
									headerValue="请选择" theme="simple"
									cssStyle="width:155px;margin-left:5px;" id="dept"
									onchange="changeDept(this.value);"></s:select>
								<span style="display: none;" id="countrySpan"> <s:select
										list="#{}" name="streetId" headerKey="" headerValue="请选择"
										theme="simple" cssStyle="width:155px;margin-left:5px;"></s:select>
								</span>
							</td>
						</tr>
						<tr>
							<td class="title_td">
								职务：
							</td>
							<td>
								<s:select list="zwList" name="userZw" listKey="id"
									listValue="name" headerKey="" headerValue="请选择" theme="simple"
									cssStyle="width:155px;margin-left:5px;" id="bselect5"></s:select>
								<SPAN class="note4">*</SPAN>
							</td>
							<td class="title_td">
								角色：
							</td>
							<td>
								<s:select list="roleList" name="roleId" listKey="id"
									listValue="roleName" headerKey="" headerValue="请选择"
									theme="simple" cssStyle="width:155px;margin-left:5px;"
									id="bselect4"></s:select>
								<SPAN class="note4">*</SPAN>
							</td>
						</tr>
						<tr>
							<td class="title_td">
								手机：
							</td>
							<td>
								<input type="text" name="userPhone" class="info_input" value=""
									id="tel1" />
								<SPAN class="note4"></SPAN>
							</td>
							<td class="title_td">
								邮箱：
							</td>
							<td>
								<input type="text" name="userEmail" class="info_input" value=""
									id="email1" />
								<SPAN class="note4"></SPAN>
							</td>
						</tr>
						<tr>
							<td colspan="4" align="center">
								<center>
									<input type="submit" name="btntj" class="link_input"
										id="btnSubmit1" value="提 交" onclick="return toSubmit();">
									<input type="reset" name="btnset" class="link_input"
										id="btnset" value="重 置">
									<input type="button" name="btn1" class="link_input"
										id="btnset1" value="返 回"
										onclick="window.location.href='<%=basePath%>/admin/sys_userList.action'">
								</center>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</body>
</html>
